package org.opens.excel.service;

import org.opens.excel.entity.EasyPoiEntity;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

@Service
public class EasyPoiEntityService {

    public List<EasyPoiEntity> getEasyPoiEntityNyNum(Integer num) {
        if (num > 30) {
            num = 30;
        }

        List<EasyPoiEntity> easyPoiEntities = new ArrayList<>(num);

        Random random = new Random();

        for (int i = 0; i < num; i++) {
            EasyPoiEntity entity = new EasyPoiEntity();
            entity.setCreateDate(new Date());
            entity.setAccuracy(random.nextFloat());
            entity.setDoubleAccuracy(random.nextDouble());
            entity.setId(random.nextInt());
            entity.setName("test");
            entity.setPrice(new BigDecimal("23.23"));
            entity.setTotalPrice(new BigDecimal("23.231"));

            easyPoiEntities.add(entity);
        }

        return easyPoiEntities;
    }

}
